Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(font): ios13+ font loading error #2684

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

real-jacket
Copy link

@real-jacket real-jacket commented Aug 28, 2021

Summary

In ios 13+, documents fonts loaded,but documents.fonts.ready(promise) do not resolve but in pending,So that the whole process is pending. i add a status check to resolve this.When fonts is already loaded,it don't need to do the ready.

Closing issues

Fixes #2191

In ios 13+, documents fonts loaded,but documents,fonts.ready not resolve but in pending,so that whole process is pending.
@real-jacket real-jacket changed the title fix(font): ios13+ font loading errror fix(font): ios13+ font loading error Aug 29, 2021
@sxlfzhy
Copy link

sxlfzhy commented Jan 11, 2022

encountered this problem too, this change can solve the problem when fonts loaded. suggested to add a timeout for fonts.ready, like this:
await Promise.race([documentClone.fonts.ready, new Promise((resolve) => setTimeout(resolve, 1000))]);

or

 function fontReady() {
    if (documentClone.fonts && documentClone.fonts.status === 'loading') {
        return Promise.race([
            documentClone.fonts.ready,
            new Promise<void>((resolve) => {
                const fontLoadTimer = setInterval(() => {
                    if (documentClone.fonts.status === 'loaded') {
                        clearInterval(fontLoadTimer);
                        resolve();
                    }
                }, 1000);
            })
        ]);
    }
}

@real-jacket
Copy link
Author

yes , you're correct ! we need to handle when font loaded timeout.I commited it again.

@sxlfzhy
Copy link

sxlfzhy commented Jan 18, 2022

@niklasvh pleas attention this commit,thank you!

@tcatche
Copy link

tcatche commented Mar 24, 2022

This pr help fix my problem, tks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ios13.4 is not working,How to solve!!!
3 participants